package com.qwiki.text;

import java.util.Collections;
import java.util.List;

/**
 * @author xgu
 * 
 * @since Jun 9, 2012
 */
public class TagNode extends Node
{
  private static String startTag = "<";
  private static String endTag = ">";
  private static String slash = "/";

  @Override
  public String getText()
  {
    return " ";
  }

  @Override
  public List<Node> getChildren()
  {
    return Collections.EMPTY_LIST;
  }

  @Override
  public boolean parse(char[] buffer, int start)
  {
    this.start = start;
    this.buffer = buffer;
    int i = start;
    int tagnamea = i;
    int tagnameb = i;
    if (match(buffer, start, startTag))
    {
      // in a tag opening
      i += startTag.length();
      tagnamea = tagnameb = i;
      while (i < buffer.length)
      {
        // parse end of TagNode
        if (match(buffer, i, endTag))
        {
          tagnameb = i;
          end = i + endTag.length();
          parsed = true;
          return true;
        }
        i++;
      }
    }
    return false;
  }
}
